<?php

declare (strict_types=1);


namespace App\Models\GameDB\Fantasy;

use App\Models\MainDB\Gift;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class GiftTemplate extends Model
{
    protected $connection = 'mysql_game';
    protected $table = 'lottery_fantasy_gift_template';
    //protected $fillable = [];
    protected $guarded = [];

    //protected $casts = ['id' => 'int', 'user_id' => 'integer', 'amount' => 'integer', 'balance' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function one(array $filters)
    {
        return self::query()->where($filters)->first();
    }

    public function listAll(array $filters, $fields)
    {
        return self::query()->where($filters)->select($fields)->get();
    }

    public function getGiftListByIds(array $templateIds, array $fields)
    {
        return self::query()->select($fields)->whereIn('id', $templateIds)->get();
    }

    public function gift()
    {
        return $this->hasOne(\App\Models\MainDB\Gift::class, 'id', 'gift_id');
    }






}